<template>
  <el-dialog v-model="crud.dialogFormVisible" :title="crud.formtitle" width="520px">
    <el-form :model="crud.form" :label-width="crud.formLabelWidth">
      <el-form-item label="用户名" prop="username">
        <el-input v-model="crud.form.username" />
      </el-form-item>
      <el-form-item label="真实姓名" prop="name">
        <el-input v-model.number="crud.form.name" />
      </el-form-item>
      <el-form-item label="昵称" prop="nickName">
        <el-input v-model="crud.form.nickName" />
      </el-form-item>
      <el-form-item label="邮箱" prop="email">
        <el-input v-model="crud.form.email" />
      </el-form-item>
      <el-form-item label="部门" prop="departmentId">
        <treeselect v-model="crud.form.departmentId" :options="props.deptlist" style="width: 178px"
          placeholder="选择部门" />
      </el-form-item>
      <el-form-item label="状态">
        <el-radio-group v-model="crud.form.status">
          <el-radio v-for="item in enabledlist" :key="item.id" :label="item.id">{{ item.label }}</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="角色" prop="roles">
        <el-select v-model="crud.form.roles" style="width: 437px" multiple placeholder="请选择">
          <el-option v-for="item in rolelist" :key="item.value" :label="item.name" :value="item.id" />
        </el-select>
      </el-form-item>
      <el-form-item label="备注" prop="remark">
        <el-input v-model="crud.form.remark" type="textarea" />
      </el-form-item>
    </el-form>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="crud.dialogFormVisible = false">取消</el-button>
        <el-button type="primary" @click="crud.submitCU()">确定</el-button>
      </span>
    </template>
  </el-dialog>

</template>
<script setup lang="ts">
import { crud, CRUD } from '/@/crud/crud';


// import Treeselect from '@riophae/vue-treeselect'
import Treeselect from 'vue3-treeselect'
// import the styles
import 'vue3-treeselect/dist/vue3-treeselect.css'
// import '@riophae/vue-treeselect/dist/vue-treeselect.css'

const props = defineProps({
  deptlist: { type: Array },
  rolelist: null,
});



const search = () => {
  if (crud.formtitle == '新增用户') {

    crud.form.status = 1
  }

}

search()

const enabledlist = [{ label: "启用", id: 1 }, { label: "禁用", id: 0 }]

</script>